enum control_mode {
    //% block="开环"
    0,
    //% block="闭环"
    1,
}

//% color="#AA278D" iconWidth=50 iconHeight=40
namespace S05_MD {

//% block="初始化库 默认串口1"   blockType="command"
export function init(parameter: any, block: any) {
    Generator.addInclude('S05_MD', '#include <S05_MD.h>');
    Generator.addObject('s05md', 'S05_MD', `s05md(1);`);
}

//% block=" id:[ID]  转速:[RPM]rpm  模式:[MOD]" blockType="command"
//%  ID.shadow="range"    ID.params.min=0         ID.params.max=255      ID.defl=0
//% RPM.shadow="range"   RPM.params.min=-1000    RPM.params.max=1000    RPM.defl=0
//% MOD.shadow="dropdown"   MOD.options="control_mode"     MOD.defl="control_mode.1"

export function set_speed(parameter: any, block: any) {
    let id = parameter.ID.code
    let rpm = parameter.RPM.code
    let mod = parameter.MOD.code
    Generator.addCode(`s05md.set_speed(${id}, ${rpm}, ${mod});//正转控制`)
}



    function replace(str :string) {
        return str.replace("+", "");
    }
}
